import java.util.Scanner;
public class turn {
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            System.out.print("请输入需要翻转的字符串：");
            String s = input.nextLine();
            System.out.println("翻转之后的字符串为："+reverseStr(s));
        }

        public static String reverseStr(String s){
            //1.以空格分隔字符串，放到数组中
            String[] s1 = s.split(" ");

            //2.定义一个字符串newString，用来存放新的字符串
            StringBuffer newStr = new StringBuffer();

            for (String arr:s1) {
                StringBuffer reverseStr = new StringBuffer(arr);
                reverseStr.reverse();//实现翻转
                newStr.append(reverseStr);//放入翻转之后的新的字符串
                newStr.append(" ");
            }
            return newStr.toString();
        }


}
